package ru.amse.tsyganov.jumleditor.view;

import java.util.List;

import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;

import ru.amse.tsyganov.jumleditor.model.ActivityGraph;
import ru.amse.tsyganov.jumleditor.model.Partition;
import ru.amse.tsyganov.jumleditor.model.State;
import ru.amse.tsyganov.jumleditor.properties.PropertiesList;
import ru.amse.tsyganov.jumleditor.properties.StringProperty;

public class PartitionView<T extends Partition> extends ViewElement<T> {
	
	private final ActivityGraphView<? extends ActivityGraph> activityGraphView; 
	
	public PartitionView(T model,
			ActivityGraphView<? extends ActivityGraph> activityGraphView) {
		
		super(model);
		this.activityGraphView = activityGraphView;
	}

	@Override
	public void paint(GC gc) {
		assert gc != null;
		
		for (State s : getModel().getContents()) {
			StateView<? extends State> stateView = 
				getModelViewMap().getStatesMap().get(s);
			stateView.paintTransitions(gc);
		}
		
		for (State s : getModel().getContents()) {
			StateView<? extends State> stateView = 
				getModelViewMap().getStatesMap().get(s);
			stateView.paint(gc);
		}
	}

	@Override
	public void accept(Visitor v) {
		if (activityGraphView == null) {
			throw new IllegalStateException();
		}
		
		v.visitPartitionView(this);
		for (State s : getModel().getContents()) {
			StateView<? extends State> stateView = 
				getModelViewMap().getStatesMap().get(s);
			stateView.accept(v);
		}
	}

	@Override
	public List<? extends ActivePoint> getActivePoints() {
		// TODO: when support for partition appear
		return null;
	}
	
	public ActivityGraphView<? extends ActivityGraph> getActivityGraphView() {
		return activityGraphView;
	}

	@Override
	public void paintActivePoints(GC gc) {
		// TODO: when support for partition appear	
	}
	
	@Override
	public PropertiesList getProperties() {
		// TODO: when support for partition appear
		return null;
	}

	@Override
	public StringProperty getMainProperty() {
		// TODO: when support for partition appear
		return null;
	}

	@Override
	public Point getCenterPoint() {
		// TODO: when support for partition appea
		return null;
	}
}
